const data = [
    { name: "js", price: 100 },
    { name: "mysql", price: 212 },
    { name: "vue.js", price: 98 }
];

class Lesson {
    constructor(data) {
        // 就是将课程信息压进model里， 然后一个model对应一个对象就对了
        this.model = data;
    }
    get price() {
        return this.model.price;
    }
    get name() {
        return this.model.name;
    }
    //批量生成对象
    static createBatch(data) {
        return data.map(item => new Lesson(item));
    }
    //最贵的课程
    static MaxPrice(collection) {
        return collection.sort((a, b) => b.price - a.price)[0];
    }
}
const lessons = Lesson.createBatch(data);
console.log(lessons);
console.log(Lesson.MaxPrice(lessons).name);


console.log('aaa  bbb    '.replace('/\s$/g', ''))
